package pl.mcnova.model.table;

import java.util.List;

import pl.mcnova.model.entity.Device;

public class DevicesSmallTableModel extends TableModel<Device> {

	public DevicesSmallTableModel(List<Device> devices) {
		super(devices);
	}

	@Override
	public Object getValueAt(int rowIndex, int columnIndex) {
		if (rowIndex > -1 && rowIndex < data.size() && columnIndex > -1 && columnIndex < classNames.length) {

			if (data.get(rowIndex) == null) {
				if (columnIndex == 0)
					return rowIndex + 1;
				else
					return null;
			}

			Device d = data.get(rowIndex);

			switch (columnIndex) {
			case 0:
				return d.getProducer();
			case 1:
				return d.getModel();
			default:
				return null;
			}
		} else {
			return null;
		}
	}

	@Override
	public void setColumns() {
		columnNames = new String[] { "Producent", "Model" };
		classNames = new Class[] { String.class, String.class };

	}

}
